package com.jd.financeweb.controller;

import com.alibaba.fastjson.JSON;
import com.jd.financeweb.pojo.dto.GetOverDueDTO;
import com.jd.financeweb.service.RepayService;
import com.jd.financeweb.service.impl.RepayServiceImpl;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/getUserOverDue")
public class OverRepayUserController extends HttpServlet {

    RepayService repayService=new RepayServiceImpl();

    /**
     * 根据uid查询  个人用户 还款逾期的产品
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }

    @Override
    protected void doPost(@RequestBody HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String idNo=req.getParameter("idNo");

//        String response;

        List<GetOverDueDTO> response = repayService.getUserOverInfo(idNo);
        String s = JSON.toJSONString(response);

        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html");

        PrintWriter out = resp.getWriter();

        out.println(s);
        out.flush();
        out.close();
    }
}
